<template>
  <div class="">
    <ul>
      <li v-for="(item, index) in $store.state.list" :key="item.id">
        <span>{{ item.name }}</span>
        <span>{{ item.price }}</span>
        <el-input-number
          v-model="item.num"
          :min="1"
          :max="10"
          @change="change"
          label="描述文字"
        ></el-input-number>
        <span @click="remove(index)">x</span>
      </li>
    </ul>
    总价是：{{ $store.getters.sum }}
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {},
  methods: {
    remove(index) {
      this.$store.commit("remove", index);
    },
    change() {
      console.log("1111");
      this.$store.commit("change");
    },
  },
  components: {},
};
</script>

<style lang="scss"></style>
